﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ParsecParser.Display
{
    public class ThreatDisplayItem
    {
        public string Name { get; set; }
        public long Threat { get; set; }
        //public double Tps { get; set; }
        //private double Pct { get; set; }
        public int ThreatColorValue { get; set; }
        public int ThreatBackgroundValue { get; set; }
        public ThreatDisplayItem()
        {

        }
        
        public ThreatDisplayItem(string displayName, long displayThreat)
        {
            Threat = displayThreat;
            //Tps = x.Tps;
            Name = displayName;
        }
        public ThreatDisplayItem(bool tankMode, string displayName, long displayThreat, long userThreat, string userName, long topThreat, string topName)
        {
            Threat = displayThreat;
            //Tps = x.Tps;
            Name = displayName;
            SetDisplayColor(tankMode, userThreat, userName, topThreat, topName);
        }
        public void SetDisplayColor(bool tankMode, long userThreat, string userName, long topThreat, string topName)
        {
            if (tankMode)
            {
                double pct = (double)((double)Threat / (double)userThreat);
                ThreatBackgroundValue = 0;
                if (Name == userName)
                {
                    ThreatBackgroundValue = 1;
                    if (Name != topName)
                        ThreatColorValue = 1;
                    else
                        ThreatColorValue = 3;
                }
                else
                {
                    if (pct >= 1.15)
                    {
                        ThreatColorValue = 1;
                    }
                    else if (pct >= .9)
                    {
                        ThreatColorValue = 2;
                    }
                    else
                    {
                        ThreatColorValue = 3;
                    }
                }
            }
            else
            {
                double pct = (double)((double)Threat / (double)topThreat);
                ThreatBackgroundValue = 0;
                if (Name == userName)
                    ThreatBackgroundValue = 1;
                if (Name == topName)
                    ThreatColorValue = 1;
                else
                {
                    if (pct >= .9)
                    {
                        ThreatColorValue = 1;
                    }
                    else if (pct >= .7)
                    {
                        ThreatColorValue = 2;
                    }
                    else
                    {
                        ThreatColorValue = 3;
                    }
                }
            }
        }
        
    }
}
